import {appConfig} from './../service/common';
import {Injectable, Inject} from '@angular/core'; // PS: 依赖注入
import {Headers, Http, RequestOptions, Response, URLSearchParams} from '@angular/http';
import {DA_SERVICE_TOKEN, ITokenService, SocialOpenType, SocialService} from '@delon/auth';

@Injectable()
export  class CommondictServe {
    constructor(private http: Http,
                @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService
    ) {}
    // 根据业务字典key查询字典值
        dictItem: any;
      queryDictKey(key, myheaders?) {
          myheaders = {Authorization: 'Bearer ' + this.tokenService.get().token}
          // 配置请求头
          const myHeaders: Headers = new Headers();
          // tslint:disable-next-line:forin
          for (const key in myheaders) {
              myHeaders.append(key, myheaders[key]);
          }
          return this.http.get(appConfig.serverUrl  + appConfig.API.queryListByDictKey + '/' + key, { headers: myHeaders })
              .map(res => res.json());
    }
}
